package com.fare.taluo.application.impl.system.email;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fare.taluo.application.system.email.ReportEmailApplication;
import com.fare.taluo.core.domain.system.EmailEntity;
import com.fare.taluo.vo.reportemail.EmailVO;
@Transactional
@Scope("singleton")
@Service("reportEmailApplication")
public class ReportEmailApplicationImpl implements ReportEmailApplication{

	@Override
	public List<EmailVO> findAllEmail(int statu) {
		EmailEntity entity=new EmailEntity();
		List<EmailVO> listVo=new ArrayList<EmailVO>();
		List<EmailEntity> listEntity=new ArrayList<EmailEntity>();
		try{
			listEntity=entity.findAllEmail(statu);
			listVo=this.listEmailVo(listEntity);
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		return listVo;
	}

	private List<EmailVO> listEmailVo(List<EmailEntity> listEntity){
		List<EmailVO> listVo=new ArrayList<EmailVO>();
		for(EmailEntity entity:listEntity){
			listVo.add(this.emailVo(entity));
		}
		
		return listVo;
	}
	
	private EmailVO emailVo(EmailEntity entity){
		EmailVO vo=new EmailVO();
		vo.setEmailAddress(entity.getEmailAddress());
		vo.setId(entity.getId());
		vo.setStatu(entity.getStatu());
		vo.setUserName(entity.getUserName());
		return vo;
	}
}
